 <?php
echo $html->css ( 'jquery-validate/css/screen' );
echo $html->css ( 'tab' );
//echo $javascript->link('jquery-1.4.2');
echo $javascript->link('checkRepeat');
echo $html->css('start/jquery-ui-1.8.2.custom');
//echo $javascript->link('jquery-ui-1.8.2.custom.min');
?>
<script>
//添加验证
$(document).ready(function() {
	
	$.validator.setDefaults({       
		 submitHandler: function(form) { 
		//if($("#CandidatemobilePhone").val()!=""){
			//if(verifyName()==false){
				//alert("该寻访人已存在，手机号码重复！");
				//}
			//else{
			//	 form.submit();  
			//}
		 // }
		//else	
			form.submit(); 
		}       
	});   
			
	$("#f1").validate({
		rules: {
		"data[Candidate][name]":{
		required: true,formatOfName:true,stringMinLength:0,stringMaxLength:50//人名 
		},
		"data[Candidate][tel]":{
			required: false,phone:true//电话
			},
		"data[Candidate][email]":{
			required: false,email:true//电子邮件
			},
		"data[Candidate][mobilePhone]":{
			required: false,mobile:true//手机
			},
		"data[Candidate][remindBefore]":{
			required: false,digits:true
			},
		"data[Candidate][remindSpacing]":{
			required: false,digits:true
			},
		"data[Candidate][visitorMind]":{
			required: true
			}
		},
		messages: {
		},
		//设置验证触发事件 
		focusInvalid: false, 
		onkeyup: false, 
		//设置错误信息提示DOM  
		errorPlacement: function(error, element) { 
		error.appendTo( element.parent()); 
		}
	});
});
</script>
<script type="text/javascript">
	function mycheck() {
		var EmailMailboxServer=$("#CandidatePreviousCompany").val();
		var EmailPortNumber=$("#CandidatePosition").val();
		var EmailYourEmail=$("#CandidateName").val();
		var EmailUsername=$("#CandidateWorkarea").val();
		var EmailPassword=$("#CandidateIndustry").val();
		var tel=$("#CandidateTel").val();
		var mobilePhone=$("#CandidateMobilePhone").val();
		if($.trim(EmailMailboxServer)==""||$.trim(EmailPortNumber)==""||$.trim(EmailYourEmail)==""||$.trim(EmailUsername)==""||$.trim(EmailPassword)=="")
		{
			alert("请您认真填写");
			return false;
		}	
		else
		{
			if($.trim(tel)=="" && $.trim(mobilePhone)=="")
			{
				alert("请您认真填写");
				return false;
			}
			else
			{
				$("#f1").submit();	
			}
		}
	}
	$(function()
			{
				$("#deletefile").click(function(){
					file = $("#ff");   
					file.after(file.clone());   
					file.remove(); 
				});
			});
	$(document).ready(function(){
		$("#coldSubmit").click(function(){
			var tel=$("#CandidateTel").val();
			var mobilePhone=$("#CandidateMobilePhone").val();
			if($.trim(tel)=="" && $.trim(mobilePhone)=="")
			{
				alert("工作电话和手机必须填写一个");
				return;
			}
			
			var serach=$("#CandidateMobilePhone").val();
			if(serach!="")
			{
				var param= [{name:"field",value:"Resume.mobilePhone"},{name:"value",value:serach}];
				  flag=true;
				  $.ajax({
					  type: 'POST',
					   url: "<?php echo ROOT_WEB_PATH; ?>/resumes/resumeCheck",
					   async: false,
					   data: param,
					   dataType:"xml",
					   success: function(xml)
					   {
					  		$(xml).find("aaa").each(function(i){
					  			 var id = $(this).text();
					  			 if(id=="no")
					  			 {
					  				 alert("该手机号已存在");
					  				$("#CandidateMobilePhone").val("");
					  				return;
					  			 }
					  		});
					   }
					 });
			}

			var serach=$("#CandidateEmail").val();
			if(serach!="")
			{
				var param= [{name:"field",value:"Resume.email"},{name:"value",value:serach}];
				  flag=true;
				  $.ajax({
					  type: 'POST',
					   url: "<?php echo ROOT_WEB_PATH; ?>/resumes/resumeCheck",
					   async: false,
					   data: param,
					   dataType:"xml",
					   success: function(xml)
					   {
					  		$(xml).find("aaa").each(function(i){
					  			 var id = $(this).text();
					  			 if(id=="no")
					  			 {
					  				 alert("该邮箱地址已存在");
					  				$("#CandidateEmail").val("");
					  				return;
					  			 }
					  		});
					   }
					 });
			}
			$("#f1").submit();	
			});
		
		$("#ResumeIndustry1").change(function(){
			var IndustryDroptoplist = $(this).val();
			if(IndustryDroptoplist!="")
			{
				$("#visitorrecordsindustry").val($("#ResumeIndustry1 option:selected").text() + "_");
				$.post("<?php echo ROOT_WEB_PATH; ?>/industries/industriesQuery/",{
					Industry : $(this).val()
					},
				function(data,textStatus){
						 $("#ResumeIndustry2:eq(0)>option").remove();
						 $(data).find("aaa").each(function(){
						//	 alert($(this).attr("name"));
						 $("#ResumeIndustry2:eq(0)").append("<option></option>");
						 $("#ResumeIndustry2:eq(0)>option:last").val($(this).attr("name")).html($(this).text());
					  });
					});
			}
			else
			{
				$("#ResumeIndustry2:eq(0)>option").remove();
				$("#ResumeIndustry2:eq(0)").append("<option></option>");
				$("#ResumeIndustry2:eq(0)>option:last").val("").html("不选");
				$("#resumesindustry").val("");
			}
		});
		$("#ResumeIndustry2").change(function(){
			var IndustryDroptoplist = $(this).val();
			if(IndustryDroptoplist!="")
			{
				$("#visitorrecordsindustry").val($("#ResumeIndustry1 option:selected").text() + "_" + $("#ResumeIndustry2 option:selected").text());
			}
			else
			{
				$("#visitorrecordsindustry").val($("#ResumeIndustry1 option:selected").text() + "_");
			}
		});
	});

	$(document).ready(function(){
		$("#ResumeCompetency1").change(function(){
			var CompetencyDroptoplist = $(this).val();
			//alert(CompetencyDroptoplist);
			if(CompetencyDroptoplist!="")
			{
				$("#visitorrecordscompetency").val($("#ResumeCompetency1 option:selected").text() + "_");
				$.post("<?php echo ROOT_WEB_PATH; ?>/competencies/getcompetencies/",{
					Competency : $(this).val()
					},function(data,textStatus){
						 $("#ResumeCompetency2:eq(0)>option").remove();
						 $(data).find("aaa").each(function(){
						 $("#ResumeCompetency2:eq(0)").append("<option></option>");
						 $("#ResumeCompetency2:eq(0)>option:last").val($(this).attr("name")).html($(this).text());
						 $("#ResumeCompetency3:eq(0)>option").remove();
						 $("#ResumeCompetency3:eq(0)").append("<option></option>");
						 $("#ResumeCompetency3:eq(0)>option:last").val("").html("不限");
					  });
					});
			}
			else
			{
				$("#ResumeCompetency2:eq(0)>option").remove();
				$("#ResumeCompetency2:eq(0)").append("<option></option>");
				$("#ResumeCompetency2:eq(0)>option:last").val("").html("不限");
				$("#ResumeCompetency3:eq(0)>option").remove();
				$("#ResumeCompetency3:eq(0)").append("<option></option>");
				$("#ResumeCompetency3:eq(0)>option:last").val("").html("不限");
				$("#visitorrecordscompetency").val("");
			}
		});
	});

	//职能三层字段 级联菜单 //
	$(document).ready(function(){
		$("#ResumeCompetency2").change(function(){
			var list = $(this).val();
			if(list!="")
			{
				$("#visitorrecordscompetency").val($("#ResumeCompetency1 option:selected").text() + "_" + $("#ResumeCompetency2 option:selected").text() + "_");
				$.post("<?php echo ROOT_WEB_PATH; ?>/competencies/getcompetencies/",{
					Competency : $(this).val()
					},function(data,textStatus){
						 $("#ResumeCompetency3:eq(0)>option").remove();
						 $(data).find("aaa").each(function(){
						//	 alert($(this).attr("name"));
						 $("#ResumeCompetency3:eq(0)").append("<option></option>");
						 $("#ResumeCompetency3:eq(0)>option:last").val($(this).attr("name")).html($(this).text());					 
					  });
					});
			}
			else
			{
				$("#ResumeCompetency3:eq(0)>option").remove();
				$("#ResumeCompetency3:eq(0)").append("<option></option>");
				$("#ResumeCompetency3:eq(0)>option:last").val("").html("不限");
				$("#visitorrecordscompetency").val($("#ResumeCompetency1 option:selected").text() + "_");
			}
		});
		$("#ResumeCompetency3").change(function(){
			var list = $(this).val();
			if(list!="")
			{
				if($("#ResumeCompetency1 option:selected").text()!="不限")
				$("#visitorrecordscompetency").val($("#ResumeCompetency1 option:selected").text() + "_" + $("#ResumeCompetency2 option:selected").text() + "_" + $("#ResumeCompetency3 option:selected").text());
				else
				$("#visitorrecordscompetency").val("");
			}
			else
			{
				if($("#ResumeCompetency1 option:selected").text()!="不限")
				$("#visitorrecordscompetency").val($("#ResumeCompetency1 option:selected").text() + "_" + $("#ResumeCompetency2 option:selected").text() + "_");
				else
				$("#visitorrecordscompetency").val("");
			}
		});
	});

	$(document).ready(function(){
		$("#ResumePosition1").change(function(){
			var IndustryDroptoplist = $(this).val();
			if(IndustryDroptoplist!="")
			{
				$("#position").val($("#ResumePosition1 option:selected").text() + "_");
				$.post("<?php echo ROOT_WEB_PATH; ?>/positions/getPosition/",{
					Position : $(this).val()
					},
				function(data,textStatus){
						 $("#ResumePosition2:eq(0)>option").remove();
						 $(data).find("aaa").each(function(){
						//	 alert($(this).attr("name"));
						 $("#ResumePosition2:eq(0)").append("<option></option>");
						 $("#ResumePosition2:eq(0)>option:last").val($(this).attr("name")).html($(this).text());
					  });
					});
			}
			else
			{
				$("#ResumePosition2:eq(0)>option").remove();
				$("#ResumePosition2:eq(0)").append("<option></option>");
				$("#ResumePosition2:eq(0)>option:last").val("").html("不限");
				$("#position").val("");
			}
		});
		$("#ResumePosition2").change(function(){
			var IndustryDroptoplist = $(this).val();
			if(IndustryDroptoplist!="")
			{
				$("#position").val($("#ResumePosition1 option:selected").text() + "_" + $("#ResumePosition2 option:selected").text());
			}
			else
			{
				$("#position").val($("#ResumePosition1 option:selected").text() + "_");
			}
		});
	});
	//省份城市
	$(function(){
		//省份级联菜单 //
			$("#CandidateProvinceId").change(function(){
				var workareaf = "" ;
				var list = $(this).val();
				$("#visitorrecordsworkarea").val($("#CandidateProvinceId option:selected").text() + '-');
				if(list!="")
				{
					$.post("<?php echo ROOT_WEB_PATH; ?>/cities/getProvince/",{
						provicnceid : $(this).val()
						},
					function(data,textStatus){
							 $("#CandidateCityId:eq(0)>option").remove();
							 $(data).find("aaa").each(function(){
							// alert($(this).attr("name"));
							 $("#CandidateCityId:eq(0)").append("<option></option>");
							 $("#CandidateCityId:eq(0)>option:last").val($(this).attr("name")).html($(this).text());

						  });
						if($("#CandidateCityId option:selected").html() != null){		  
								 workareaf = $("#CandidateProvinceId option:selected").text() + '-' +$("#CandidateCityId option:selected").html();
						}
						else{
							workareaf = $("#CandidateProvinceId option:selected").text() + '-';
						}
						$("#visitorrecordsworkarea").val(workareaf);
							  
					});
				}
			});
			$("#CandidateCityId").change(function(){
				var citylist = $(this).val();
				if(citylist!="")
				{
					if($("#CandidateProvinceId option:selected").text()!=""&&$("#CandidateCityId option:selected").text()!="")
					$("#visitorrecordsworkarea").val($("#CandidateProvinceId option:selected").text() + "-" + $("#CandidateCityId option:selected").text());
					else
					$("#visitorrecordsworkarea").val("");
				}
				else
				{
					if($("#CandidateProvinceId option:selected").text()!=""&&$("#CandidateProvinceId option:selected").text()!="")
					$("#visitorrecordsworkarea").val($("#CandidateProvinceId option:selected").text() + "-");
					else
					$("#visitorrecordsworkarea").val("");
				}
			});
	});	
</script>
<style>
.input{
	float:left;
}
</style>

<div id="tabmenubar">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td class="tabmenubartitle1"><?php echo  __('YourPosition');//您现在的位置：?></td>
		<td class="tabmenubartitle2"><?php echo __('Projectmanagements');//一级目录
										   echo '>';echo __('Projectmanagements');//二级目录
										   echo '>';echo __('Candidate Management');//三级目录
										   echo '>';?>
									<?php echo $html->tag('span', __('Cold Call',true));//当前操作地用span加粗?> 						  
		</td>

	</tr>
</table>
</div>
<div class="tabflex">
<fieldset><legend><?php echo __('Cold Call')?></legend>
<?php echo $form->create('Candidate',array('action'=>'coldcall','type'=> 'post','id'=>'f1'));?>
<?php echo $form->hidden('projectmanagement_id',array('default'=>$projectid));?>
<?php  $op9=array(""=>"不限");?>
<table width="100%" cellspacing="0" cellpadding="0" border="0"
	style="text-align: left">
		<tr>
		<td></td>
		<td><?php __('当前行业');?>:</td>
		<td colspan="4">
		<?php 
					echo $form->input('industry1',array('empty' =>'不限','options'=>$op1,'label'=>false,'div'=>false,'class'=>'TextBoxE2','id'=>'ResumeIndustry1'));		
				?>

		<?php echo $form->input('industry2',array('options'=>$op9,'label'=>false,'div'=>false,'class'=>'TextBoxE2','id'=>'ResumeIndustry2'));		
				?>

		<?php 
			echo $form->hidden('industry',array('id'=>'visitorrecordsindustry'));
		?>
		</td>
		
		<!--<td width="50"></td>
		<td width="100">行业:</td>
		<td width="100">
		<?php 
			//echo $form->input('industry',array('options'=>$op1,'label'=>false,'div'=>false,'class'=>'TextBoxE1'));	
		?>
		</td>
		-->
		</tr>
		<tr>
		<td width="5%"></td>
		<td width="10%">公司:</td>
		<td width="35%">
		<?php 
			echo $form->input('previousCompany',array('options'=>$op2,'label'=>false,'div'=>false,'class'=>'TextBoxE2'));	
		?>
		</td>

		<td  width="5%"></td>
		<td  width="10%">学历:</td>
		<td  width="35%">
		<?php 
			echo $form->input('advancedDegree',array('options'=>$op3,'label'=>false,'div'=>false,'class'=>'TextBoxE1'));
		?>
		</td>
		</tr>
		
		<tr>
		<td></td>
		<td >职能:</td>
		<td colspan="4">
		<?php 
			echo $form->input('competency1',array('options'=>$op8,'label'=>false,'div'=>false,'class'=>'TextBoxE2','id'=>'ResumeCompetency1'));
		?>
		<?php 
			echo $form->input('competency2',array('options'=>$op9,'label'=>false,'div'=>false,'class'=>'TextBoxE2','id'=>'ResumeCompetency2'));
		?>
		<?php 
			echo $form->input('competency3',array('options'=>$op9,'label'=>false,'div'=>false,'class'=>'TextBoxE2','id'=>'ResumeCompetency3'));
		?>
		<?php 
			echo $form->hidden('competency',array('id'=>'visitorrecordscompetency'));
		?>
		</td>
		</tr>
		
		<tr>
		<td></td>
		<td>部门:</td>
		<td>
		<?php 
			echo $form->input('department',array('options'=>$op4,'label'=>false,'div'=>false,'class'=>'TextBoxE1'));
		?>
		</td>
		<td></td>
		<td>职位:</td>
		<td>
		<?php 
			echo $form->input('position1',array('options'=>$op5,'label'=>false,'div'=>false,'class'=>'TextBoxE1','id'=>'ResumePosition1'));
		?>
		<?php 
			echo $form->input('position2',array('options'=>$op9,'label'=>false,'div'=>false,'class'=>'TextBoxE1','id'=>'ResumePosition2'));
		?>
		<?php 
			echo $form->hidden('position',array('id'=>'visitorrecordsposition'));
		?>
		</td>
		</tr>
		<tr>
		<td></td>
		<td>姓名:<font color="red">*</font></td>
		<td>
		<?php 
			echo $form->input('name',array('label'=>false,'div'=>false,'class'=>'TextBoxE1'));	
		?>
		</td>
		<td></td>
		<td>性别:</td>
		<td>
		<?php 
			echo $form->input('sex',array('options'=>$op7,'label'=>false,'div'=>false,'class'=>'TextBoxE1'));
		?>
		</td>
		</tr>
		
		<tr>

		<td ></td>
		<td >工作电话:</td>
		<td>
		<?php 
			echo $form->input('tel',array('label'=>false,'div'=>false,'class'=>'TextBoxE1'));
		//echo $form->input('reminder',array('options'=>$op1,'label'=>false,'div'=>false,'class'=>'TextBoxE1'));	
			//echo $form->input('reminder',array('label'=>false));
		?>
		</td>
		<td></td>
		<td >手机:</td>
		<td>
		<?php 
			echo $form->input('mobilePhone',array('label'=>false,'class'=>'TextBoxE1'));
			echo "<input type='button' value='检测手机号' class='setting' id='checkPhone' /></input>"?>
		</td>
		</tr>
		<tr>
		<td></td>
		<td>现工作地区:</td>
		<td>
		<?php echo $form->text('workarea',array('label'=>false,'id'=>'visitorrecordsworkarea','value'=>$visitorFieldDefault,'readOnly'=>true));?>
			<?php $options = array();
					foreach($provinces as $eachrecord)
					{
						$options[$eachrecord['Province']['id']] = $eachrecord['Province']['name'];
					}
					echo $form->input('province_id',array('options'=>$options,'label'=>false,'div'=>false,'default'=>$provinceid));
				?>
			<?php $options = array();
					foreach($cities as $eachrecord)
					{
						$options[$eachrecord['City']['id']] = $eachrecord['City']['name'];
					}
					echo $form->input('city_id',array('options'=>$options,'label'=>false,'div'=>false,'default'=>$cityid));
			 ?>	
			 <?php echo $form->hidden('visitorFieldDefault',array('value'=>$visitorFieldDefault,'id'=>'visitorFieldDefault'));?>		
		</td>
		<td></td>
		<td>电子邮件:</td>
		<td>
		<?php 
			echo $form->input('email',array('label'=>false,'class'=>'TextBoxE1'));
		?>
		<?php echo "<input type='button' value='检测电子邮件' class='setting' id='checkEmail' ></input>"?>
		</td>
		</tr>
		
		<tr>

		</tr>
		<tr>
		<td ></td>
		<td  style="vertical-align:top;">寻访状态:</td>
		<td  colspan="4">
		<?php 
			echo $form->input('visitorstate',array('options'=>$op6,'label'=>false,'div'=>false,'class'=>'TextBoxE1'));
		?>
		</td>
		</tr>
		<tr>
		<td></td>
		<td>联系时间:</td>
		<td >
		<?php 
			echo $form->input('linkTime',array('type'=>'datetime','label'=>false,'monthNames' => false,'dateFormat'=>'YMD', 'timeFormat'=> '24','div'=>false));
		?>
		</td>
		<td></td>
		<td >提前提醒:</td>
		<td>
		<?php 
			echo $form->input('remindBefore',array('label'=>false,'div'=>false));
		?>天
		</td>
		</tr>
		<tr>
		<td ></td>
		<td>下次联系时间:</td>
		<td>
		<?php 
			echo $form->input('nextLinkTime',array('type'=>'datetime','monthNames' => false,'label'=>false,'dateFormat'=>'YMD', 'timeFormat'=> '24','div'=>false));
			?>
		</td>
		<td></td>
		<td>间隔提醒:</td>
		<td>
		<?php 
			echo $form->input('remindSpacing',array('label'=>false,'div'=>false));
		?>分
		</td>
		</tr>
		<tr>
		<td></td>
		<td style="vertical-align:top;">寻访记录:<font color="red">*</font></td>
		<td  colspan="4">
		<?php 
			echo $form->textarea('visitorMind',array('label'=>false,'class' => 'TextArea1 txtOut'));
		?>
		</td>
		</tr>
</table>
</fieldset>
<table width="100%" cellspacing="0" cellpadding="0" border="0" style="text-align: left">
	<tr>
		<td width="50"></td>
		<td width="100"><?php echo $form->button('确定',array('type'=>'button','class'=>'oksubmit','id'=>'coldSubmit'));?>  <!-- __('reset', true)取消-->
		<td width="100"><?php echo $form->button('重置',array('type'=>'reset','class'=>'resetsubmit'));?>  <!-- __('reset', true)取消-->
		</td>
	</tr>
</table>
<?php echo $form->end();?>

